package com.hhs.storage.controller;


import com.hhs.storage.bean.Comsumer;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.ProductSupplier;
import com.hhs.storage.bean.ResponseInfo;
import com.hhs.storage.service.ProductSupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hhs
 * @since 2023-01-04
 */
@RestController
@RequestMapping("/productSupplier")
public class ProductSupplierController {
    @Autowired
    private ProductSupplierService productSupplierService;
    @RequestMapping(value = "table")
    public Map<String, Object> getAll(ProductSupplier productSupplier,InputParam inputParam) {
        return productSupplierService.getAll(productSupplier,inputParam);
    }
    @PostMapping(value = "edit")
    public Map<String, Object> addOrUpdate(ProductSupplier productSupplier,String deleIdStr, MultipartFile[] qualificationCertificateList){
        return productSupplierService.addOrUpdate(productSupplier,deleIdStr,qualificationCertificateList);
    }
    @PostMapping(value = "dele")
    public Map dele(String id) {
        try{
            return productSupplierService.dele(id);
        }catch (Exception e){
            return ResponseInfo.error("存在关联业务，无法删除");
        }
    }
}

